<?php $this->load->view('includes/header'); ?>
		
<script type="text/javascript">
	$(document).ready(function(){
		$("#list2").jqGrid({
		   	url:'<?= base_url() ?>index.php/user/getUsers',
		   	editurl: '<?= base_url() ?>index.php/user/edit',
			datatype: "json",
			mtype : "post",
		   	colNames:['Id','Username', 'Name', 'Lastname','Email'],
		   	colModel:[
		   		{name:'id',index:'id', width:100},
		   		{name:'username',index:'username', width:200},
		   		{name:'name',index:'name', width:180},
		   		{name:'lastname',index:'lastname', width:180},
		   		{name:'email',index:'email', width:190}
		   	],
		   	rowNum:10,
		   	rowList:[10,20,30],
		   	pager: '#pager2',
		   	sortname: 'id',
		    sortorder: "asc",
		    viewrecords: true,
		    caption:"Users List"
		});
		jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false, search:false, del:false});
		$("#list2").navButtonAdd('#pager2', {  
			 caption: "New User",   
			 title: "Click here to create a user",   
			 buttonicon: "ui-icon-plusthick",   
			 onClickButton: function() { 
				 location.href= CI.baseUrl + "index.php/user/createUser";
			  },   position: "first" })
		.navButtonAdd('#pager2', {  
			 caption: "Edit User",   
			 title: "Edit selected user",   
			 buttonicon: "ui-icon-edit",   
			 onClickButton: function() { 
				 var selr = jQuery('#list2').jqGrid('getGridParam','selrow');
				 var myForm = document.createElement("form");
				 myForm.method="post";
				 myForm.action = CI.baseUrl + "index.php/user/editUser";
				 var myInput = document.createElement("input") ;
				 myInput.setAttribute("name", "idUser") ;
				 myInput.setAttribute("type", "hidden");
				 myInput.setAttribute("value", selr);
				 myForm.appendChild(myInput);
				 document.body.appendChild(myForm) ;
				 myForm.submit() ;
			  },   position: "last" })
		.navButtonAdd('#pager2', {  
			 caption: "Delete User",   
			 title: "Delete selected user",   
			 buttonicon: "ui-icon-del",   
			 onClickButton: function() { 
				 var selr = jQuery('#list2').jqGrid('getGridParam','selrow');
				 var myForm = document.createElement("form");
				 myForm.method="post" ;
				 myForm.action = CI.baseUrl + "index.php/user/delete";
				 var myInput = document.createElement("input") ;
				 myInput.setAttribute("name", "idUser") ;
				 myInput.setAttribute("type", "hidden");
				 myInput.setAttribute("value", selr);
				 myForm.appendChild(myInput);
				 document.body.appendChild(myForm) ;
				 myForm.submit() ;
		     },   position: "last" });
	});
</script>

		<table id="list2"></table> 
		<div id="pager2"></div>
	</body>
</html>